package javalearning.fileoperate.fileWorker;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author ThinkPad
 */
public class FileOperate {
    public static void main(String[] args) throws IOException {
        System.out.println("FileOperate begins");
        FileUtils fileUtils = new FileUtils();
        Path fromPath = fileUtils.getPath();
        fileUtils.getFile();
//        System.out.println("FromPath:"+fromPath);
        Path toPath = fromPath.resolveSibling("another");
//        System.out.println("To  Path:"+toPath);
        //Files.copy(fromPath, toPath, StandardCopyOption.REPLACE_EXISTING);
        System.out.println("successful!");
    }
}

class FileUtils {

    public Path getPath() {
        return Paths.get("D:\\资料\\电子书\\新建文件夹", "A");
    }

    public void getFile() throws IOException {
        File file1 = new File("D:\\test\\aa.txt");
        File file2 = new File("D:\\test", "aa.txt");
        File file3 = new File("D:\\test");
        File file4 = new File(file3, "aa.txt");
        file3.mkdir();
//        file1.createNewFile();
        String file = "D:\\test\\demo";
        File file5 = new File("D:\\test\\demo");
        System.out.println(file5.lastModified());
        File[] ss = file5.listFiles();
        for (File s : ss) {
            System.out.println(s.getName());
        }
        System.out.println(file5.getAbsolutePath());
        System.out.println(file5.getName());
    }
}
